function showChart1() {
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('main'));
    // 指定图表的配置项和数据
    var option1 = {
        title: {
            text: '电压:'+datarequired[datarequired.length-1]['voltage']+'V',
            x: 'center'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                animation: false
            }
        },
        toolbox: {
            feature: {
                restore: {},
                saveAsImage: {}
            }
        },

        dataZoom: [
            {
                show: true,
                realtime: true,
                start: 90,
                end: 100,
                xAxisIndex: [0],
                filterMode: 'empty'
            },{
                type: 'inside',
                realtime: true,
                start: 30,
                end: 70,
                xAxisIndex: [0]
            }
        ],
        grid: [{
            left: 50,
            right: 50,
            height: '50%'
        }],
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                axisLine: {onZero: true},
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['time']);
                    }
                    return res;
                })(),
                scale: true
            }
        ],
        yAxis : [
            {
                name : '电压(V)',
                type : 'value',
                scale: true
            }
        ],
        series : [
            {
                name:'电压',
                type:'line',
                xAxisIndex: 0,
                yAxisIndex: 0,
                symbolSize: 8,
                hoverAnimation: true,
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['voltage']);
                    }
                    return res;
                })()
            }
        ]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart1.setOption(option1);
}
function showChart2(){
    // 基于准备好的dom，初始化echarts实例
    var myChart2 = echarts.init(document.getElementById('second'));
    // 指定图表的配置项和数据
    var option2 = {
        title: {
            text: '电流:'+datarequired[datarequired.length-1]['current']+'A',
            x: 'center'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                animation: false
            }
        },
        toolbox: {
            feature: {
                restore: {},
                saveAsImage: {}
            }
        },

        dataZoom: [
            {
                show: true,
                realtime: true,
                start: 90,
                end: 100,
                xAxisIndex: [0],
                filterMode: 'empty'
            },{
                type: 'inside',
                realtime: true,
                start: 30,
                end: 70,
                xAxisIndex: [0]
            }
        ],
        grid: [{
            left: 50,
            right: 50,
            height: '50%'
        }],
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                axisLine: {onZero: true},
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['time']);
                    }
                    return res;
                })(),
                scale: true
            }
        ],
        yAxis : [
            {
                name : '电流(A)',
                type : 'value',
                scale: true
            }
        ],
        series : [
            {
                name:'电流',
                type:'line',
                xAxisIndex: 0,
                yAxisIndex: 0,
                symbolSize: 8,
                hoverAnimation: true,
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['current']);
                    }
                    return res;
                })()
            }
        ]

    };
    myChart2.setOption(option2);
}
function showChart3(){
    // 基于准备好的dom，初始化echarts实例
    var myChart3 = echarts.init(document.getElementById('third'));
    // 指定图表的配置项和数据
    var option3 = {
        title: {
            text: '瞬时功率:'+datarequired[datarequired.length-1]['power']+'W',
            x: 'center'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                animation: false
            }
        },
        toolbox: {
            feature: {
                restore: {},
                saveAsImage: {}
            }
        },

        dataZoom: [
            {
                show: true,
                realtime: true,
                start: 90,
                end: 100,
                xAxisIndex: [0],
                filterMode: 'empty'
            },{
                type: 'inside',
                realtime: true,
                start: 30,
                end: 70,
                xAxisIndex: [0]
            }
        ],
        grid: [{
            left: 50,
            right: 50,
            height: '50%'
        }],
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                axisLine: {onZero: true},
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['time']);
                    }
                    return res;
                })(),
                scale: true
            }
        ],
        yAxis : [
            {
                name : '瞬时功率(W)',
                type : 'value',
                scale: true
            }
        ],
        series : [
            {
                name:'瞬时功率',
                type:'line',
                xAxisIndex: 0,
                yAxisIndex: 0,
                symbolSize: 8,
                hoverAnimation: true,
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['power']);
                    }
                    return res;
                })()
            }
        ]
    };
    myChart3.setOption(option3);
}
function showChart4(){
    // 基于准备好的dom，初始化echarts实例
    var myChart4 = echarts.init(document.getElementById('fourth'));
    // 指定图表的配置项和数据
    var option4 = {
        title: {
            text: '能耗:'+datarequired[datarequired.length-1]['energyConsumption']+'kW.h',
            x: 'center'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                animation: false
            }
        },
        toolbox: {
            feature: {
                restore: {},
                saveAsImage: {}
            }
        },

        dataZoom: [
            {
                show: true,
                realtime: true,
                start: 90,
                end: 100,
                xAxisIndex: [0],
                filterMode: 'empty'
            },{
                type: 'inside',
                realtime: true,
                start: 30,
                end: 70,
                xAxisIndex: [0]
            }
        ],
        grid: [{
            left: 50,
            right: 50,
            height: '50%'
        }],
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                axisLine: {onZero: true},
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['time']);
                    }
                    return res;
                })(),
                scale: true
            }
        ],
        yAxis : [
            {
                name : '能耗(kW.h)',
                type : 'value',
                scale: true
            }
        ],
        series : [
            {
                name:'能耗',
                type:'line',
                xAxisIndex: 0,
                yAxisIndex: 0,
                symbolSize: 8,
                hoverAnimation: true,
                data: (function(){
                    var res = [];
                    for(var i = 0; i < datarequired.length; i++) {
                        res.push(datarequired[i]['energyConsumption']);
                    }
                    return res;
                })()
            }
        ]
    };
    myChart4.setOption(option4);
}